<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>统计 ArrayObject 内 public 属性的数量</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="arrayobject.construct.html">« ArrayObject::__construct</a></li>
      <li style="float: right;"><a href="arrayobject.exchangearray.html">ArrayObject::exchangeArray »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.arrayobject.html">ArrayObject</a></li>
    <li>统计 ArrayObject 内 public 属性的数量</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="arrayobject.count" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ArrayObject::count</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ArrayObject::count</span> &mdash; <span class="dc-title">统计 ArrayObject 内 public 属性的数量</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-arrayobject.count-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ArrayObject::count</strong></span>(): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   获取 <span class="classname"><a href="class.arrayobject.html" class="classname">ArrayObject</a></span> 的 public 属性数量
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-arrayobject.count-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-arrayobject.count-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   对象 <span class="classname"><a href="class.arrayobject.html" class="classname">ArrayObject</a></span> 的 public 属性数量
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    当对象 <span class="classname"><a href="class.arrayobject.html" class="classname">ArrayObject</a></span> 是从数组构造而来时，所有属性都是 public 的。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 examples" id="refsect1-arrayobject.count-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3733">
    <p><strong>示例 #1 <span class="methodname"><strong>ArrayObject::count()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Example&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$public&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'prop:public'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;</span><span style="color: #0000BB">$prv&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'prop:private'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;</span><span style="color: #0000BB">$prt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'prop:protected'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$arrayobj&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ArrayObject</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">Example</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$arrayobj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">count</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$arrayobj&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ArrayObject</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'first'</span><span style="color: #007700">,</span><span style="color: #DD0000">'second'</span><span style="color: #007700">,</span><span style="color: #DD0000">'third'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$arrayobj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">count</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
int(1)
int(3)
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
</div></div></div></body></html>